import Vue from 'vue'
import  Vuex from 'vuex'

Vue.use(Vuex);

var store=new Vuex.Store({
    state:{
        header_title:'gallery',
        login_data:{
            user_name:'',
            user_password:'',
            user_icon:defalutIcon,
            isLogined:false,
        },
        register_data:{
            user_name:'',
            user_password:'',
            user_icon:defalutIcon
        },

    },
    mutations:{
        //最多提交两个参数，第一个默认为state，
        //第二个才是组件传的参数，如果想传递多个参数，
        //第二个参数可以用对象
        setTitle(state,title){
            state.header_title=title;
        },

        setLoginedUserIcon(state,icon){
            state.login_data.user_icon=icon;
        },

        setLoginedUserName(state,name){
            state.login_data.user_name=name
        },
        
        setLoginedUserPassword(state,password){
            state.login_data.user_password=password
        },

        setRegisterIcon(state,icon){
            state.register_data.user_icon=icon
        },
        setRegisterName(state,name){
            state.register_data.user_name=icon
        },
        setRegisterPassword(state,password){
            state.register_data.user_password=password
        }
    }
})

export default store